<script type="text/javascript">
  var str = "Doe, John";
  document.write(str.replace(/(\w+)\s*, \s*(\w+)/, "$2 $1"));
</script>